*************************************************************************
* "Unimplementable by design" (GOVE-2020-311)
* (Replication file) 
*************************************************************************

****************************************************************
* Data
****************************************************************

  cd "E:\_imf\IMFCMP\Submissions\Governance\Final version"
  use "GOVE-replication", clear
  
  qui g lngdppc=ln(gdppc)
  qui g lnbkexp=ln(1+bkexp)
  qui g lnoda=ln(3.5+oda_pc_WDI)

  g w=100*waiv2/totb
  lab var w "Waiver percentage"
  qui g anyinter=(intpermcor==1 |inttemp==1)
  su w int*
  
  g tp=0
  replace tp=1 if ayear>=1990
  replace tp=2 if ayear>=2000
  lab var tp "Time period"
  
  cmp setup
  qui xi:reg w i.cid i.tp i.ayear i.regid
  global C _Icid* 
  global T _Itp* 
  
  
************************************************************
* Descriptive table
************************************************************
 
** Table 1 ** 
  preserve
   g N=1
   collapse (sum)N anyinter inttemp intpermcor 
   list
  restore  
  
  corr intpermcor inttemp w 
  tab intpermcor inttemp


****************************************************************
* Multivariate analysis 
****************************************************************

  global Ctrl  w adur loanquota0 lidc _It* _Iregid*     
  global Econ0  lngdppc gdp_growth_WDI cab_gdp_WDI reserves_WDI debtser_gni_WDI
  global Pol0  p_polity2_QOG polconiii left0 capacity 
  global IntPol0  unsc_DSV s_unga3us lnbkexp lnoda
  global BurPol0  first0 cmp5_perm learn_perm_ig 
  global Econ1  dintrus anycrisis dcab dres ddsgni 
  global Pol1  dpolity dpolcon anyexelec anylegelec civwar
  
  
* Probit models
***************

  mat Diag1=J(2,5,0)
  mat Diag2=J(2,5,0)

  local m=1
  foreach y in intpermcor anyinter{
  
    qui probit `y' BA2TOT $Ctrl, ro cl(cid)
	est store a`m'1
	mat Diag`m'[1,1]=e(N)
	mat Diag`m'[2,1]=e(r2_p)
	
	qui probit `y' BA2TOT $Econ0 $Econ1 $Ctrl, ro cl(cid)
	est store a`m'2
    mat Diag`m'[1,2]=e(N)
	mat Diag`m'[2,2]=e(r2_p)
	
    qui probit `y' BA2TOT $Pol0 $Pol1 $Ctrl, ro cl(cid)
	est store a`m'3
    mat Diag`m'[1,3]=e(N)
	mat Diag`m'[2,3]=e(r2_p)
	
	qui probit `y' BA2TOT $IntPol0 $Ctrl, ro cl(cid)
	est store a`m'4
    mat Diag`m'[1,4]=e(N)
	mat Diag`m'[2,4]=e(r2_p)
  
	qui probit `y' BA2TOT $BurPol0 $Ctrl, ro cl(cid)
	est store a`m'5
	mat Diag`m'[1,5]=e(N)
	mat Diag`m'[2,5]=e(r2_p)
  
  local m=`m'+1
  }

** Table 2 ** 
estout a1* using "GOVE-2.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons _I*) 
mat li Diag1 

** Marginal effects **
  est restore a11
  mfx, at(BA2TOT=23.8)
  di normal(e(Xmfx_y))
  mfx, at(BA2TOT=37.6)
  di normal(e(Xmfx_y))
  
  
* IV design 
***********
  
  egen niso3=mean(BA2TOT), by(iso3)
  g ivn=niso3*nUnder
    
  mat DiagB1=J(5,5,0)
  mat DiagB2=J(5,5,0)
  local m=1
  
  foreach y in intpermcor anyint{
  	
	qui cmp (`y'=BA2TOT $Ctrl) (BA2TOT=ivn nUnder niso3 $Ctrl), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store b`m'1
	 mat DiagB`m'[1,1]=e(N1)
	 mat DiagB`m'[3,1]=e(N2)
	 qui test ([BA2TOT]ivn)
	 mat DiagB`m'[5,1]=`r(chi2)'
	 mat DiagB`m'[2,1]=Diag`m'[2,1]
	 qui reg BA2TOT ivn nUnder niso3 $Ctrl 
	 mat DiagB`m'[4,1]=e(r2)
	
	qui cmp (`y'=BA2TOT $Econ0 $Econ1 $Ctrl) (BA2TOT=ivn nUnder niso3 $Econ0 $Econ1 $Ctrl), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store b`m'2
	 mat DiagB`m'[1,2]=e(N1)
	 mat DiagB`m'[3,2]=e(N2)
	 qui test ([BA2TOT]ivn)
	 mat DiagB`m'[5,2]=`r(chi2)'
	 mat DiagB`m'[2,2]=Diag`m'[2,1]
	 qui reg BA2TOT ivn nUnder niso3 $Econ0 $Econ1 $Ctrl 
	 mat DiagB`m'[4,2]=e(r2)
	 
	qui cmp (`y'=BA2TOT $Pol0 $Pol1 $Ctrl) (BA2TOT=ivn nUnder niso3 $Pol0 $Pol1 $Ctrl), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store b`m'3
     mat DiagB`m'[1,3]=e(N1)
	 mat DiagB`m'[3,3]=e(N2)
	 qui test ([BA2TOT]ivn)
	 mat DiagB`m'[5,3]=`r(chi2)'
	 mat DiagB`m'[2,3]=Diag`m'[2,1]
	 qui reg BA2TOT ivn nUnder niso3 $Pol0 $Pol1 $Ctrl 
	 mat DiagB`m'[4,3]=e(r2)
	 
	qui cmp (`y'=BA2TOT $IntPol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $IntPol0 $Ctrl), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store b`m'4
	 mat DiagB`m'[1,4]=e(N1)
	 mat DiagB`m'[3,4]=e(N2)
	 qui test ([BA2TOT]ivn)
	 mat DiagB`m'[5,4]=`r(chi2)'
	 mat DiagB`m'[2,4]=Diag`m'[2,1]
	 qui reg BA2TOT ivn nUnder niso3 $IntPol0 $Ctrl 
	 mat DiagB`m'[4,4]=e(r2)
	 
	qui cmp (`y'=BA2TOT $BurPol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $BurPol0 $Ctrl), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store b`m'5
	 mat DiagB`m'[1,5]=e(N1)
	 mat DiagB`m'[3,5]=e(N2)
	 qui test ([BA2TOT]ivn)
	 mat DiagB`m'[5,5]=`r(chi2)'
	 mat DiagB`m'[2,5]=Diag`m'[2,1]
	 qui reg BA2TOT ivn nUnder niso3 $BurPol0 $Ctrl 
	 mat DiagB`m'[4,5]=e(r2)
	
	local m=`m'+1
	}
	
** Table 3 ** 
estout b1* using "GOVE-3.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons _I*) 
mat li DiagB1

** Marginal effects **
  est restore b11
  mfx, predict(xb eq(#1)) at(BA2TOT=23.8)
  di normal(e(Xmfx_y))
  mfx, predict(xb eq(#1)) at(BA2TOT=37.6)
  di normal(e(Xmfx_y))
  
    
  
********************************************************
* Supplemental appendix
********************************************************

  global XIV  adur loanquota0 lidc_IMF cab_gdp_WDI reserves_WDI debtser_gni_WDI dintrus anycrisis dcab dres p_polity2_QOG dpolity anylegelec first0 learn_perm_ig _It* _Ireg*


* Effect heterogeneity 
**********************

  mat S=J(3,4,0)

** Preference heterogeneity ** 
 
  su cov_g7, d
  g above=cov_g7>`r(p50)'
  g below=cov_g7<=`r(p50)'
  
  qui probit intpermcor BA2TOT $Econ0 $Pol0 $Ctrl if below, ro cl(cid)
   est store a4a1
   mat S[1,1]=e(N)
   mat S[2,1]=e(r2_p)
  qui cmp (intpermcor=BA2TOT $Econ0 $Pol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $Econ0 $Pol0 $Ctrl), indicators(below $cmp_cont) cl(cid) iterate(50)
   est store a4a2 
  qui probit intpermcor BA2TOT $Econ0 $Pol0 $Ctrl if above, ro cl(cid)
   est store a4a3
   mat S[1,3]=e(N)
   mat S[2,3]=e(r2_p)
  qui cmp (intpermcor=BA2TOT $Econ0 $Pol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $Econ0 $Pol0 $Ctrl), indicators(above $cmp_cont) cl(cid) iterate(50)
   est store a4a4
  
** Negotiation time (McDowell 2017) **

  su lag, d
  g Long=(lag>`r(p50)')
  g Short=(lag<`r(p50)')
  
  qui probit intpermcor BA2TOT $Econ0 $Pol0 $Ctrl if Short, ro cl(cid)
   est store a4b1
   mat S[1,1]=e(N)
   mat S[2,1]=e(r2_p)
  qui cmp (intpermcor=BA2TOT $Econ0 $Pol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $Econ0 $Pol0 $Ctrl), indicators(Short $cmp_cont) cl(cid) iterate(50)
   est store a4b2 
  qui probit intpermcor BA2TOT $Econ0 $Pol0 $Ctrl if Long, ro cl(cid)
   est store a4b3
   mat S[1,3]=e(N)
   mat S[2,3]=e(r2_p)
  qui cmp (intpermcor=BA2TOT $Econ0 $Pol0 $Ctrl) (BA2TOT=ivn nUnder niso3 $Econ0 $Pol0 $Ctrl), indicators(Long $cmp_cont) cl(cid) iterate(50)
   est store a4b4
  
** Table A4 **
estout a4a*, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(BA2TOT)
estout a4b*, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(BA2TOT)
mat li S  

  
* Main results using any interruption
*************************************

** Table A5 ** 
estout a2* using "GOVE-A5.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_cons _I*) 
mat li Diag2  


* Scope of conditionality
*************************

  mat DiagS=J(5,4,0)
  
  local m=1
  foreach y in intpermcor anyinter{
  
    qui probit `y' scope w $XIV, ro cl(cid)
	est store a3a`m'
	mat DiagS[1,2*`m'-1]=e(N)
	mat DiagS[2,2*`m'-1]=e(r2_p)
	
	qui cmp (`y'=scope w $XIV) (scope=ivn nUnder niso3 w $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid)
	est store a3b`m'
	 qui test ([scope]ivn)
	 mat DiagS[5,2*`m']=`r(chi2)'
	 mat DiagS[1,2*`m']=e(N1)
	 mat DiagS[3,2*`m']=e(N2)
	 mat DiagS[2,2*`m']=DiagS[2,2*`m'-1]
	 qui reg scope ivn nUnder niso3 w $XIV 
	 mat DiagS[4,2*`m']=e(r2)
  
  local m=`m'+1
  }

** Table A6 **	
estout a3a1 a3b1 a3a2 a3b2 using "GOVE-A6.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(scope: _*) 
mat li DiagS

	
	
* Non-binding conditions  
************************

  g NONBTOT=IBsTOT+SBsTOT
  
  local m=1
  foreach y in intpermcor anyinter{
  
    qui probit `y' BA2TOT NONBTOT w $XIV, ro cl(cid)
	est store a6a`m'
	mat DiagS[1,2*`m'-1]=e(N)
	mat DiagS[2,2*`m'-1]=e(r2_p)
	
	qui cmp (`y'=BA2TOT NONBTOT w $XIV) (BA2TOT=ivn nUnder niso3 NONBTOT w $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid)
	est store a6b`m'
	 qui test ([BA2TOT]ivn)
	 mat DiagS[5,2*`m']=`r(chi2)'
	 mat DiagS[1,2*`m']=e(N1)
	 mat DiagS[3,2*`m']=e(N2)
	 mat DiagS[2,2*`m']=DiagS[2,2*`m'-1]
	 qui reg BA2TOT ivn nUnder niso3 NONBTOT w $XIV 
	 mat DiagS[4,2*`m']=e(r2)
  
  local m=`m'+1
  }

** Table A7 **	
estout a6a1 a6b1 a6a2 a6b2 using "GOVE-A7.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(BA2TOT: _*) 
mat li DiagS
 

* Fixed effects 
***************
 
  local m=1
  foreach y in intpermcor anyinter{
  
    qui clogit `y' BA2TOT w $XIV, group(cid) vce(cl cid)
	est store a7a`m'
	mat DiagS[1,2*`m'-1]=e(N)
	mat DiagS[2,2*`m'-1]=e(r2_p)
	
	qui cmp (`y'=BA2TOT w $XIV _Icid*) (BA2TOT=ivn nUnder niso3 w $XIV _Icid*), indicators($cmp_cont $cmp_cont) ro cl(cid)
	est store a7b`m'
	 qui test ([BA2TOT]ivn)
	 mat DiagS[5,2*`m']=`r(chi2)'
	 mat DiagS[1,2*`m']=e(N1)
	 mat DiagS[3,2*`m']=e(N2)
	 mat DiagS[2,2*`m']=DiagS[2,2*`m'-1]
	 qui reg BA2TOT ivn nUnder niso3 w $XIV _Icid* 
	 mat DiagS[4,2*`m']=e(r2)
  
  local m=`m'+1
  }

** Table A8 **	
estout a7a1 a7b1 a7a2 a7b2 using "GOVE-A8.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(BA2TOT: _*) 
mat li DiagS
 

	
* Other instruments 
*******************

  egen ba=mean(BA2TOT), by(ayear)

  egen regbastart=sum(BA2TOT), by(regid ayear)
  egen n=count(BA2TOT), by(regid ayear)
  g iv=(regbastart-BA2TOT)/(n-1)
  lab var iv "Average number of conditions in other regional programs in same start year"
    
  local m=1
  foreach y in intpermcor anyinter{
  
    qui probit `y' BA2TOT w $XIV, ro cl(cid)
	est store b3a`m'
	mat DiagS[1,2*`m'-1]=e(N)
	mat DiagS[2,2*`m'-1]=e(r2_p)
	
	qui cmp (`y'=BA2TOT w $XIV) (BA2TOT=regbastart w $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid)
	est store b3b`m'
	 qui test [BA2TOT]regbastart
	 mat DiagS[5,2*`m'-1]=`r(chi2)'
	 mat DiagS[1,2*`m'-1]=e(N1)
	 mat DiagS[3,2*`m'-1]=e(N2)
	 mat DiagS[2,2*`m'-1]=DiagS[2,2*`m'-1]
	 qui reg BA2TOT regbastart w $XIV
	 mat DiagS[4,2*`m'-1]=e(r2)
	 
	qui cmp (`y'=BA2TOT w $XIV) (BA2TOT=ba w $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid)
	
	est store b3c`m'
	 qui test [BA2TOT]ba
	 mat DiagS[5,2*`m']=`r(chi2)'
	 mat DiagS[1,2*`m']=e(N1)
	 mat DiagS[3,2*`m']=e(N2)
	 mat DiagS[2,2*`m']=DiagS[2,2*`m'-1]
	 qui reg BA2TOT ba w $XIV
	 mat DiagS[4,2*`m']=e(r2)
	 
  local m=`m'+1
  }

** Table A9 ** 
estout b3b* b3c* using "GOVE-A9.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop( _*) 
mat li DiagS
 
 
* Other conditions on policy areas
**********************************

  mat Diag1=J(2,8,0)
  mat Diag2=J(2,8,0)
  
  local k=1
  
  foreach y in intpermcor anyint{
  
  local m=1
  
  foreach x in BA2LAB BA2PRI BA2SOE BA2EXT BA2FIN BA2FP BA2INS BA2RTP{
   
	di "`x':"
	g IX=`x'
    
	qui probit `y' BA2TOT IX w $XIV, ro cl(cid) 
	est store r`k'`m'
	mat Diag`k'[1,`m']=e(N)
	mat Diag`k'[2,`m']=e(r2_p)
	
	drop IX
	local m=`m'+1
	}
	local k=`k'+1
	}

** Table A10 **	
estout r1* using "GOVE-A10.rtf", starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(BA2TOT IX)
mat li Diag1 
estout r2*, starlevels(* .1 ** .05 *** .01) cells(b(star fmt(3)) se(par fmt(3))) keep(BA2TOT IX)
mat li Diag2



* Replicating everything on MONA
********************************

  g lnBA2TOT=ln(1+BA2TOT)
  g lnfail_nm=ln(1+fail_nm)
  g lnfail=ln(1+fail)
  
  qui xtreg lnfail_nm lnBA2TOT $Econ0 $Econ1 _Iayear*, fe ro cl(cid)
   est store mona11
  qui xtreg lnfail_nm lnBA2TOT p_polity2 dpolity anyexelec anylegelec civwar _Iayear*, fe ro cl(cid)
   est store mona12
  qui xtreg lnfail_nm lnBA2TOT $IntPol0 _Iayear*, fe ro cl(cid)
   est store mona13
  qui xtreg lnfail_nm lnBA2TOT $BurPol0 _Iayear*, fe ro cl(cid)
   est store mona14
  
  qui xtreg lnfail lnBA2TOT $Econ0 $Econ1 _Iayear*, fe ro cl(cid)
   est store mona21
  qui xtreg lnfail lnBA2TOT p_polity2 dpolity anyexelec anylegelec civwar _Iayear*, fe ro cl(cid)
   est store mona22
  qui xtreg lnfail lnBA2TOT $IntPol0 _Iayear*, fe ro cl(cid)
   est store mona23
  qui xtreg lnfail lnBA2TOT $BurPol0 _Iayear*, fe ro cl(cid)
   est store mona24
   
** Table A11 **
estout mona2* using "GOVE-A11.rtf", starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) stats(N r2_w, fmt(0 2)) order(*BA* ) drop(_I* _cons)
  
  

* Disbursement share
********************

  g share=totaldrawn/totalsdr*100
  su share
  lab var share "Disbursement share"
 
  g undrawn=(share>0 & share<100)

  mat XDiag=J(5,4,0)
  
  qui probit undrawn BA2TOT $XIV, ro cl(cid)
   est store a71
   mat XDiag[1,1]=e(N)
   mat XDiag[2,1]=e(r2_p)
   mat XDiag[1,2]=e(N)
   mat XDiag[2,2]=e(r2_p)
  
  qui cmp (undrawn=BA2TOT $XIV) (BA2TOT=ivn nUnder niso3 $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid) iterate(40) difficult
   est store a72
   qui test [BA2TOT]ivn
   mat XDiag[5,2]=r(chi2)
   qui reg BA2TOT ivn nUnder niso3 $XIV
   mat XDiag[3,2]=e(N)
   mat XDiag[4,2]=e(r2_a)
  
  
** Table A12 **  
  estout a7*, starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_I*)	
  mat li XDiag
  
 
  
 
* UNGA aligmnet with G7
*********************** 
  
  mat XDiag=J(5,4,0)
  local m=1
  
  foreach y in intpermcor anyinter{
   
    qui cmp (`y'=BA2TOT w s_unga3g7  $XIV), indicators($cmp_probit) ro cl(cid)
    est store a8a`m'
	qui cmp (`y'=BA2TOT w s_unga3g7  $XIV) (BA2TOT=ivn nUnder niso3 s_unga3g7  $XIV), indicators($cmp_probit $cmp_cont) ro cl(cid)
    est store a8b`m'
	 qui test [BA2TOT]ivn
	 mat XDiag[5,2*(`m'-1)+2]=r(chi2)
	 qui probit `y' BA2TOT w $XIV s_unga3g7 
	 mat XDiag[1,2*(`m'-1)+1]=e(N)
	 mat XDiag[2,2*(`m'-1)+1]=e(r2_p)
	 mat XDiag[1,2*(`m'-1)+2]=e(N)
	 mat XDiag[2,2*(`m'-1)+2]=e(r2_p)
	 qui reg BA2TOT ivn nUnder niso3 $XIV s_unga3g7 
	 mat XDiag[3,2*(`m'-1)+2]=e(N)
	 mat XDiag[4,2*(`m'-1)+2]=e(r2_a)
	local m=`m'+1
  }
  
** Table A13 **  
estout a8a1 a8b1 a8a2 a8b2, starlevels(* .1 ** .05 *** .01) cells((b(star fmt(3)) se(par fmt(3)))) drop(_I* _cons BA2TOT:*)	
mat li XDiag
  
  
   

* Descriptive statistics
************************

** Table A3 **
  qui estpost summarize intperm anyint BA2TOT $Ctrl $Econ0 $Econ1 $Pol0 $Pol1 $IntPol0 $BurPol0 
  esttab, cells("count mean sd min max") noobs replace label  
  
  